<?xml version="1.0"?>
<configuration>
        <!-- 开启RM高可用 -->
        <property>
            <name>yarn.resourcemanager.ha.enabled</name>
            <value>true</value>
        </property>

        <!-- 指定RM的cluster id -->
        <property>
            <name>yarn.resourcemanager.cluster-id</name>
            <value>{{ yarn_cluster_id }}</value>
        </property>

        <!-- 指定RM的逻辑名字 -->
        <property>
            <name>yarn.resourcemanager.ha.rm-ids</name>
            <value>
                {%- for rm in rm_names -%}
                    {%- set sep=',' -%}
                    {%- if loop.last -%}
                        {%- set sep='' -%}
                    {%- endif -%}
                    {{ rm }}{{ sep }}
                {%- endfor -%}
            </value>
        </property>

		{%- for rm in rm_names -%}
        <!-- 指定{{ rm }}的地址 -->
        <property>
            <name>yarn.resourcemanager.hostname.{{ rm }}</name>
            <value>{{ rm_hostnames[loop.index0] }}</value>
        </property>
		{%- endfor -%}

        <!-- 至关重要,即使默认有也要配置 -->

	    {%- for rm in rm_names -%}

        <!-- {{ rm }}的webapp地址 -->

        <property>
            <name>yarn.resourcemanager.webapp.address.{{ rm }}</name>
            <value>{{ rm_webapp_address[loop.index0] }}</value>
        </property>
		{%- endfor -%}


        <!-- 指定zk集群地址 -->
        <property>
            <name>yarn.resourcemanager.zk-address</name>
            <value>{{ zk_cluster }}</value>
        </property>

        <!--启用自动恢复-->
        <property>
            <name>yarn.resourcemanager.recovery.enabled</name>
            <value>true</value>
        </property>


        <!-- 启用自动切换 -->
        <property>
            <name>yarn.resourcemanager.ha.automatic-failover.enabled</name>
            <value>true</value>
        </property>


        <!-- 指定resourcemanager的状态信息存储在zookeeper集群 -->
        <property>
            <name>yarn.resourcemanager.store.class</name>
            <value>org.apache.hadoop.yarn.server.resourcemanager.recovery.ZKRMStateStore</value>
        </property>

         <!-- NodeManager上运行的附属服务,需配置成mapreduce_shuffle，才可运行MapReduce程序 -->
        <property>
            <name>yarn.nodemanager.aux-services</name>
            <value>mapreduce_shuffle</value>
        </property>

        <!-- 配置nm环境环境变量白名单 -->
        <property>
            <name>yarn.nodemanager.env-whitelist</name>
            <value>{{ env_whitelist }}</value>
        </property>

         <!-- yarn程序运行环境变量 -->
        <property>
            <name>yarn.application.classpath</name>
            <value>{{ hdp_classpath }}</value>
        </property>

        <!-- 让NodeManager自动检测内存和CPU -->
        <property>
            <name>yarn.nodemanager.resource.detect-hardware-capabilities</name>
            <value>true</value>
        </property>

</configuration>

